home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / idlelib / FileList.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  4KB  |  153 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import os
  5. from Tkinter import *
  6. import tkMessageBox
  7.  
  8. class FileList:
  9.     from EditorWindow import EditorWindow
  10.     
  11.     def __init__(self, root):
  12.         self.root = root
  13.         self.dict = { }
  14.         self.inversedict = { }
  15.         self.vars = { }
  16.  
  17.     
  18.     def open(self, filename, action = None):
  19.         if not filename:
  20.             raise AssertionError
  21.         filename = self.canonize(filename)
  22.         if os.path.isdir(filename):
  23.             tkMessageBox.showerror('File Error', '%r is a directory.' % (filename,), master = self.root)
  24.             return None
  25.         
  26.         key = os.path.normcase(filename)
  27.         if self.dict.has_key(key):
  28.             edit = self.dict[key]
  29.             edit.top.wakeup()
  30.             return edit
  31.         
  32.         if action:
  33.             return action(filename)
  34.         else:
  35.             return self.EditorWindow(self, filename, key)
  36.  
  37.     
  38.     def gotofileline(self, filename, lineno = None):
  39.         edit = self.open(filename)
  40.         if edit is not None and lineno is not None:
  41.             edit.gotoline(lineno)
  42.         
  43.  
  44.     
  45.     def new(self, filename = None):
  46.         return self.EditorWindow(self, filename)
  47.  
  48.     
  49.     def close_all_callback(self, event):
  50.         for edit in self.inversedict.keys():
  51.             reply = edit.close()
  52.             if reply == 'cancel':
  53.                 break
  54.                 continue
  55.         
  56.         return 'break'
  57.  
  58.     
  59.     def close_edit(self, edit):
  60.         
  61.         try:
  62.             key = self.inversedict[edit]
  63.         except KeyError:
  64.             print "Don't know this EditorWindow object.  (close)"
  65.             return None
  66.  
  67.         if key:
  68.             del self.dict[key]
  69.         
  70.         del self.inversedict[edit]
  71.         if not self.inversedict:
  72.             self.root.quit()
  73.         
  74.  
  75.     
  76.     def filename_changed_edit(self, edit):
  77.         edit.saved_change_hook()
  78.         
  79.         try:
  80.             key = self.inversedict[edit]
  81.         except KeyError:
  82.             print "Don't know this EditorWindow object.  (rename)"
  83.             return None
  84.  
  85.         filename = edit.io.filename
  86.         if not filename:
  87.             if key:
  88.                 del self.dict[key]
  89.             
  90.             self.inversedict[edit] = None
  91.             return None
  92.         
  93.         filename = self.canonize(filename)
  94.         newkey = os.path.normcase(filename)
  95.         if newkey == key:
  96.             return None
  97.         
  98.         if self.dict.has_key(newkey):
  99.             conflict = self.dict[newkey]
  100.             self.inversedict[conflict] = None
  101.             tkMessageBox.showerror('Name Conflict', 'You now have multiple edit windows open for %r' % (filename,), master = self.root)
  102.         
  103.         self.dict[newkey] = edit
  104.         self.inversedict[edit] = newkey
  105.         if key:
  106.             
  107.             try:
  108.                 del self.dict[key]
  109.             except KeyError:
  110.                 pass
  111.             except:
  112.                 None<EXCEPTION MATCH>KeyError
  113.             
  114.  
  115.         None<EXCEPTION MATCH>KeyError
  116.  
  117.     
  118.     def canonize(self, filename):
  119.         if not os.path.isabs(filename):
  120.             
  121.             try:
  122.                 pwd = os.getcwd()
  123.             except os.error:
  124.                 pass
  125.  
  126.             filename = os.path.join(pwd, filename)
  127.         
  128.         return os.path.normpath(filename)
  129.  
  130.  
  131.  
  132. def _test():
  133.     fixwordbreaks = fixwordbreaks
  134.     import EditorWindow
  135.     import sys as sys
  136.     root = Tk()
  137.     fixwordbreaks(root)
  138.     root.withdraw()
  139.     flist = FileList(root)
  140.     if sys.argv[1:]:
  141.         for filename in sys.argv[1:]:
  142.             flist.open(filename)
  143.         
  144.     else:
  145.         flist.new()
  146.     if flist.inversedict:
  147.         root.mainloop()
  148.     
  149.  
  150. if __name__ == '__main__':
  151.     _test()
  152.  
  153.